home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 21
/
Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso
/
Aminet
/
comm
/
mail
/
CfgYamIT.lha
/
configyam11italian
/
ConfigYam.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-08-14
|
28KB
|
824 lines
/******************************************************************************/
/* */
/* ConfigYam.rexx */
/* Copyright ©1997 by Dick Whiting */
/* */
/*----------------------------------------------------------------------------*/
/* This version requires MuiRexx 3.0a+ */
/*----------------------------------------------------------------------------*/
/* This allows you to easily modify the order of folders in the Yam config, */
/* rename the actual mail folders, and edit other entries. */
/* */
/* !!KNOW WHAT YOU ARE DOING!!! */
/* */
/* Turn on 'help bubbles' and USE them!! */
/* */
/*----------------------------------------------------------------------------*/
/* Select the configuration file, use drag-and-drop to reorder the lists, */
/* edit as allowed. */
/*----------------------------------------------------------------------------*/
/* */
/* Standard Disclaimer: I wrote it, it works for me, I don't guarantee */
/* that it will do anything productive for anyone else, etc. etc. ;-) */
/* */
/*HOWEVER, if you DO find a use for it: I homeschool my kids and they */
/*would love a postcard from where EVER you live. */
/* */
/*Instant GEOGRAPHY lesson;) */
/* */
/* */
/*POSTCARDS: Dick Whiting */
/* 28590 S. Beavercreek Rd. */
/* Mulino, Oregon 97042 */
/* USA */
/* */
/*----------------------------------------------------------------------------*/
/* */
/* Address Bug Reports or Comments to: */
/* Dick Whiting <dwhiting@europa.com> */
/* 13 August 1997 */
/* */
/******************************************************************************/
/*
$VER: 1.1 Copyright ©1997 by Dick Whiting
$AUTHOR: Dick Whiting
$DESCRIPTION: Quick config changes for Yam.
*/
options results
options failat 21
parse arg mainparm subparm
/**************************************************************************/
/* Initialize Variables */
/**************************************************************************/
Call MUIvars /* go define vars for MUI use */
Call CYvars /* various values used in CY */
Call Helpvars /* pointers into HELP guide */
Call Localize /* vars for localizing strings*/
Call Builtvars /* built using previous values*/
Address CONFIGYAM
Select
when mainparm='' then do
Call CheckDup
Call BuildWindow
end
when mainparm='LOAD' then do
Call LoadConfig
end
when mainparm='DELETEFLD' then do
Call DeleteFlds
end
when mainparm='EDITFLD' then do
Call EditFlds
end
when mainparm='HIDEFLD' then do
Call HideFldList
end
when mainparm='INSERTFLD' then do
Call InsertFlds
end
when mainparm='STOREFLD' then do
Call StoreFlds
end
when mainparm='DELETEMAIN' then do
Call DeleteMain
end
when mainparm='EDITMAIN' then do
Call EditMain
end
when mainparm='HIDEMAIN' then do
Call HideMainList
end
when mainparm='INSERTMAIN' then do
Call InsertMain
end
when mainparm='STOREMAIN' then do
Call StoreMain
end
when mainparm='SAVE' then do
Call SaveConfig
end
when mainparm='SAVEAS' then do
Call GetFileName
Call SaveConfig
end
when mainparm='QUIT' then do
'quit'
end
otherwise do
errmsg=_text._badparm
Call ErrorMsg
end
end
exit
/**************************************************************************/
/* Load the config file into the arrays */
/**************************************************************************/
LoadConfig:
popasl ID CYCFG
mfile=result
infotext=_text._loadfile
infobuttons=''
showbusy=TRUE
Call InfoWindow
method ID CYALL MUIM_List_Clear
method ID CYFLD MUIM_List_Clear
fldfound=FALSE
if open('IN',mfile,'R') then do
do until eof('IN')
linein=readln('IN')
Select
when upper(substr(linein,1,6))='FOLDER' then do
oldnum=word(linein,1)
oldnum=substr(oldnum,7)
parse var linein folder '=' linein
linein=translate(linein,',',';')
linein=linein||','||oldnum
list ID CYFLD INSERT POS MUIV_List_Insert_Bottom STRING linein
if ~fldfound then do
list ID CYALL INSERT POS MUIV_List_Insert_Bottom STRING '='_text._fldheader
fldfound=TRUE
end
end
otherwise do
list ID CYALL INSERT POS MUIV_List_Insert_Bottom STRING '='linein
end
end
end
foo=close('IN')
window ID CYINF close
end
else do
errmsg=_text._badfile
Call ErrorMsg
exit
end
Return
/**************************************************************************/
/* Delete line from Main Configuration */
/**************************************************************************/
DeleteMain:
list ID CYALL ATTRS MUIA_List_Active
mainpos=result
list ID CYALL POS mainpos
oldline=result
if oldline=_text._fldheader | pos(_text._yamheader,oldline)>0 then do
errmsg=_text._protected
Call ErrorMsg
exit
end
list ID CYALL REMOVE POS mainpos
Return
/**************************************************************************/
/* Edit Main Configuration */
/**************************************************************************/
EditMain:
list ID CYALL ATTRS MUIA_List_Active
mainpos=result
list ID CYALL POS mainpos
oldline=result
if oldline=_text._fldheader | pos(_text._yamheader,oldline)>0 then do
errmsg=_text._protected
Call ErrorMsg
exit
end
string ID CYMCS CONTENT oldline
Return
/**************************************************************************/
/* Insert New folder in Config */
/**************************************************************************/
InsertMain:
list ID CYALL ATTRS MUIA_List_Active
mainpos=result+1
string ID CYMCS
mainentry=result
list ID CYALL INSERT POS mainpos STRING '='mainentry
Return
/**************************************************************************/
/* Store Main Configuration Entry */
/**************************************************************************/
StoreMain:
string ID CYMCS
mainentry=result
list ID CYALL ATTRS MUIA_List_Active
mainpos=result
list ID CYALL POS mainpos STRING '='mainentry
Return
/**************************************************************************/
/* Delete a folder from the Config */
/**************************************************************************/
DeleteFlds:
list ID CYFLD ATTRS MUIA_List_Active
fldpos=result
if fldpos<4 then do
errmsg=_text._baddelete
Call ErrorMsg
end
else do
list ID CYFLD REMOVE POS fldpos
end
Return
/**************************************************************************/
/* Edit Foldre Entry */
/**************************************************************************/
EditFlds:
list ID CYFLD ATTRS MUIA_List_Active
fldpos=result
list ID CYFLD POS fldpos
oldline=result
parse var oldline ftype ',' fsort ',' ffile ',' fname ',' oldnum
string ID CYFL1 CONTENT fsort
string ID CYFL2 CONTENT ffile
string ID CYFL3 CONTENT fname
Return
/**************************************************************************/
/* Insert New folder in Config */
/**************************************************************************/
InsertFlds:
ftype=2
list ID CYFLD ATTRS MUIA_List_Entries
oldnum=result+1
list ID CYFLD ATTRS MUIA_List_Active
fldpos=result+1
if fldpos<4 then fldpos=4 /* force after system folders */
string ID CYFL1
fsort=result
string ID CYFL2
ffile=result
string ID CYFL3
fname=result
newline=ftype||comma||fsort||comma||ffile||comma||fname
list ID CYFLD INSERT POS fldpos STRING newline
StoreFoldEnd:
Return
/**************************************************************************/
/* Store Folder Entry */
/**************************************************************************/
StoreFlds:
list ID CYFLD ATTRS MUIA_List_Active
fldpos=result
list ID CYFLD POS fldpos
oldline=result
parse var oldline ftype ',' fsort ',' ffile ',' fname ',' oldnum
select
when subparm=1 then do
string ID CYFL1
newfsort=result
if newfsort>=0 & newfsort<=3 then fsort=newfsort
end
when subparm=2 then do
popasl ID CYMDR
maildir=strip(result,'B')
if maildir='' | maildir='RESULT' | ~exists(maildir) then do
errmsg=_text._badmaildir
Call ErrorMsg
exit
end
else do
lastchar=substr(maildir,length(maildir),1)
if verify(':/',lastchar,'MATCH')=0 then maildir=maildir||'/'
end
string ID CYFL2
newffile=result
if pos(':',ffile)=0 then tffile=maildir||ffile
else tffile=ffile
if pos(':',newffile)=0 then tnewffile=maildir||newffile
else tnewffile=newffile
select
when strip(newffile,'B')='' then nop
when exists(tnewffile) & upper(tffile)~=upper(tnewffile) then do
errmsg=_text._newexists
Call ErrorMsg
exit
end
when strip(ffile,'B')='' & ~exists(tnewffile) then ffile=tnewffile
when ~exists(tffile) & ~exists(tnewffile) then ffile=tnewffile
when exists(tffile) & upper(newffile)~=upper(ffile) then do
request ID CYREN GADGETS _text._renreq STRING _title._rename
if result=1 then do
address command 'Rename >nil: 'tffile tnewffile ' QUIET'
if rc=0 then do
ffile=tnewffile
end
else do
errmsg=_text._badrename||rc
Call ErrorMsg
exit
end
end
else do
signal StoreFoldEnd
end
end
otherwise nop
end
end /* end of when subparm=2 condition */
when subparm=3 then do
string ID CYFL3
fname=result
end
otherwise nop
end
newline=ftype||comma||fsort||comma||ffile||comma||fname
list ID CYFLD ATTRS MUIA_List_Active
fldpos=result
list ID CYFLD POS fldpos STRING newline
StoreFoldEnd:
Return
/**************************************************************************/
/* Get Filename for SAVEAS */
/**************************************************************************/
GetFileName:
popasl ID CYCFG
configfile=result
savfile=''
select
when lastpos('/',configfile)>0 then do
savdir=substr(configfile,1,lastpos('/',configfile)-1)
end
when lastpos(':',configfile)>0 then do
savdir=substr(configfile,1,lastpos(':',configfile))
end
otherwise do
savdir="""T:"""
end
end
aslrequest ID CYWIN TITLE _title._asl,
ATTRS ASLFR_InitialDrawer savdir ASLFR_InitialFile savfile
if rc = 0 then do
configfile=result
popasl ID CYCFG content configfile
end
else do
exit
end
Return
/**************************************************************************/
/* Save Configuration */
/**************************************************************************/
SaveConfig:
popasl ID CYCFG
configfile=result
if ~open('OUT',configfile,'W') then do
errmsg=_text._badsavefile
Call ErrorMsg
exit
end
infotext=_text._savingfile
infobuttons=''
showbusy=TRUE
Call InfoWindow
list ID CYALL ATTRS MUIA_List_Entries
acnt=result
list ID CYFLD ATTRS MUIA_List_Entries
ocnt=result
do i=0 to acnt-1
list ID CYALL POS i
lineout=result
select
when lineout=_text._fldheader then do
do j=0 to ocnt-1
list ID CYFLD POS j
lineout=result
parse var lineout ftype ',' fsort ',' ffile ',' fname ',' oldnum
lineout=ftype||';'||fsort||';'||ffile||';'||fname
fldnum='Folder'||j
lineout=left(fldnum,16,' ')||'='||lineout
foo=writeln('OUT',lineout)
end
end
otherwise do
foo=writeln('OUT',lineout)
end
end
end
foo=close('OUT')
window ID CYINF close
Return
/**************************************************************************/
/* Hide the Main Configuration list, show folder list. */
/**************************************************************************/
HideMainList:
group ID CYFLG ATTRS MUIA_ShowMe TRUE
group ID CYMCC ATTRS MUIA_ShowMe FALSE
Return
/**************************************************************************/
/* Hide the folder list, show the main configuration list. */
/**************************************************************************/
HideFldList:
group ID CYMCC ATTRS MUIA_ShowMe TRUE
group ID CYFLG ATTRS MUIA_ShowMe FALSE
Return
/**************************************************************************/
/* Make sure there isn't one running already. */
/**************************************************************************/
CheckDup:
list ID CYALL ATTRS MUIA_List_Entries
if result~='RESULT' then do
errmsg=_text._secondrun
Call ErrorMsg
exit
end
Return
/******************************************************************************/
/* Display ERROR message and EXIT. */
/******************************************************************************/
ErrorMsg:
window ID CYERR CLOSE
request ID ERRM GADGETS _text._ok errmsg
exit
Return
/******************************************************************************/
/* Display the mail in a list window. */
/******************************************************************************/
BuildWindow:
window ID CYWIN TITLE _title._main,
COMMAND '"ConfigYam.rexx QUIT"'
group
group HORIZ
popasl ID CYCFG HELP help.CYCFG CONTENT Yconfig
popasl ID CYMDR HELP help.CYMDR CONTENT maildir
button ID CYPR0 COMMAND '"ConfigYam.rexx LOAD"',
HELP help.CYPR0,
ATTRS MUIA_HorizWeight 20,
LABEL _label._CYPR0
button ID CYPR3 HELP help.CYPR3,
ATTRS MUIA_HorizWeight 20,
LABEL _label._CYPR3
endgroup
group ID CYMCC
list ID CYALL HELP help.CYALL,
COMMAND '"ConfigYam.rexx EDITMAIN"'
group HORIZ
string ID CYMCS HELP help.CYMCS,
COMMAND '"ConfigYam.rexx STOREMAIN"'
button ID CYMCZ HELP help.CYMCZ,
COMMAND '"ConfigYam.rexx DELETEMAIN"',
ATTRS MUIA_HorizWeight 20,
LABEL _label._CYMCZ
button ID CYMCI HELP help.CYMCI,
COMMAND '"ConfigYam.rexx INSERTMAIN"',
ATTRS MUIA_HorizWeight 20,
LABEL _label._CYMCI
button ID CYMCX HELP help.CYMCX,
ATTRS MUIA_HorizWeight 10,
LABEL _label._CYMCX
endgroup
endgroup
group ID CYFLG
list ID CYFLD HELP help.CYFLD,
ATTRS MUIA_Listview_DragType MUIV_Listview_DragType_Immediate,
MUIA_List_ShowDropMarks TRUE,
MUIA_List_DragSortable TRUE,
MUIA_Dropable TRUE,
MUIA_List_Format """WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,BAR,BAR,,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0"""
group HORIZ
string ID CYFL1 HELP help.CYFL1,
COMMAND '"ConfigYam.rexx STOREFLD 1"',
ATTRS MUIA_HorizWeight 10 MUIA_String_Accept sortnums
string ID CYFL2 HELP help.CYFL2,
COMMAND '"ConfigYam.rexx STOREFLD 2"',
ATTRS MUIA_HorizWeight 100
string ID CYFL3 HELP help.CYFL3,
COMMAND '"ConfigYam.rexx STOREFLD 3"',
ATTRS MUIA_HorizWeight 100
button ID CYFLZ HELP help.CYFLZ,
COMMAND '"ConfigYam.rexx DELETEFLD"',
ATTRS MUIA_HorizWeight 20,
LABEL _label._CYFLZ
button ID CYFLI HELP help.CYFLI,
COMMAND '"ConfigYam.rexx INSERTFLD"',
ATTRS MUIA_HorizWeight 20,
LABEL _label._CYFLI
button ID CYFLX HELP help.CYFLX,
ATTRS MUIA_HorizWeight 20,
LABEL _label._CYFLX
endgroup
endgroup
endgroup
group HORIZ
button ID CYPR1 COMMAND '"ConfigYam.rexx SAVE"',
HELP help.CYPR1,
LABEL _label._CYPR1
button ID CYPR2 COMMAND '"ConfigYam.rexx SAVEAS"',
HELP help.CYPR2,
LABEL _label._CYPR2
space
button ID CYPRQ COMMAND '"ConfigYam.rexx QUIT"',
HELP help.CYPRQ,
LABEL _label._CYPRQ
endgroup
endwindow
callhook ID CYPR3 PRESS PORT INLINE,
COMMAND """options results;
Address CONFIGYAM;
group ID CYFLG ATTRS " MUIA_ShowMe TRUE";
group ID CYMCC ATTRS " MUIA_ShowMe TRUE";"""
callhook ID CYMCX PRESS PORT INLINE,
COMMAND """options results;
Address CONFIGYAM;
group ID CYFLG ATTRS " MUIA_ShowMe TRUE";
group ID CYMCC ATTRS " MUIA_ShowMe FALSE";"""
callhook ID CYFLX PRESS PORT INLINE,
COMMAND """options results;
Address CONFIGYAM;
group ID CYMCC ATTRS " MUIA_ShowMe TRUE";
group ID CYFLG ATTRS " MUIA_ShowMe FALSE";"""
callhook ID CYFLD PRESS COMMAND '"ConfigYam.rexx EDITFLD"'
Return
/******************************************************************************/
/* Simple information/error message window. */
/******************************************************************************/
InfoWindow:
window ID CYINF TITLE _title._info
group
group
text ID STEXT HELP help.STEXT LABEL infotext
endgroup
if showbusy then do
group
object CLASS '"Busy.mcc"' ATTRS MUIA_VertWeight 25
endgroup
end
if infobuttons ~='' then do
group HORIZ
group
space HORIZ
endgroup
group
radio ID SQUIT HELP help.SQUIT LABELS infobuttons
endgroup
group
space HORIZ
endgroup
endgroup
end
else do
group
space HORIZ 100
endgroup
end
endgroup
endwindow
Return
/******************************************************************************/
/* MUIREXX TAGS & VARIABLES */
/******************************************************************************/
Muivars:
MUIA_Disabled = 0x80423661
MUIA_Draggable = 0x80420b6e
MUIA_Dropable = 0x8042fbce
MUIA_HorizWeight = 0x80426db9
MUIA_List_Active = 0x8042391c
MUIA_List_DragSortable = 0x80426099
MUIA_List_Format = 0x80423c0a
MUIA_List_Entries = 0x80421654
MUIA_List_Quiet = 0x8042d8c7
MUIA_List_ShowDropMarks = 0x8042c6f3
MUIA_List_Visible = 0x8042191f
MUIA_Listview_DragType = 0x80425cd3
MUIA_Listview_MultiSelect = 0x80427e08
MUIA_Selected = 0x8042654b
MUIA_ShowMe = 0x80429ba8
MUIA_String_Accept = 0x8042e3e1
MUIA_VertWeight = 0x804298d0
MUIA_Weight = 0x80421d1f
MUIA_Window_DepthGadget = 0x80421923
MUIA_Window_PublicScreen = 0x804278e4
ASLFR_InitialFile = 0x80080008
ASLFR_InitialDrawer = 0x80080009
MUIM_List_Clear = 0x8042ad89
MUIM_List_Select = 0x804252d8
TRUE=1
FALSE=0
MUIV_List_Insert_Bottom = -3
MUIV_List_Select_Off = 0
MUIV_List_Select_On = 1
MUIV_Listview_DragType_Immediate = 1
MUIV_Listview_MultiSelect_Shifted = 2
Return
/**************************************************************************/
/* Various values used throughout the various routines */
/**************************************************************************/
CYvars:
missing='.'
comma=','
tab='09'x /* tab character */
sortnums='"=0123"' /* valid sort numbers */
bo='\033b' /* print control BOLD */
bc='\033b\033c' /* print control BOLD CENTER */
yconfig="Yam:.config"
maildir="Yam:"
_text._fldheader="ConfigYam..Insert FOLDERS here"
_text._yamheader="YAM Configuration"
Return
/**************************************************************************/
/* Messages, text, etc. constructed using previously defined values */
/**************************************************************************/
Builtvars:
_title._CYALL='"'||bc||_label._cyall'"'
_title._cyfld='"'||bc||_label._cyfld'"'
_text._renreq='"'||_text._ok||'|'||_text._cancel'"'
Return
/**************************************************************************/
/* Pointers into the YamTools.guide documentation */
/**************************************************************************/
Helpvars:
Return
/**************************************************************************/
/* Mui Gadgets, text, msgs, etc. used in YamTools */
/**************************************************************************/
Localize:
/*********************************/
/* Miscellaneous info strings */
/*********************************/
_title._main="""ConfigYam v1.1""" /* main screen title */
_title._info="""ConfigYam: informazioni""" /* default title on infomsg */
_title._asl="""Seleziona un File""" /* title for ASL requester */
_title._rename="Rinomina la cartella?" /* title for ASL requester */
_text._ok="Ok" /* various OK buttons */
_text._cancel="Annulla" /* LABEL for CANCEL button */
_label._cypr0="Carica" /* label for LOAD button */
_label._cypr1="Salva" /* label for SAVE button */
_label._cypr2="Salva come" /* label for SAVEAS button */
_label._cyprq="Esci" /* label for QUIT button */
_label._cypr3="Mostra"
_label._cyfli="Inserisci"
_label._cyflx="Nascondi"
_label._cyflz="Cancella"
_label._cymci="Inserisci"
_label._cymcx="Nascondi"
_label._cymcz="Cancella"
_text._savingfile="Sto salvando la configurazione..." /* saving file message */
_text._loadfile="Sto preparando la configurazione..." /* preparing file msg */
/*********************************/
/* Various error conditions */
/*********************************/
_text._baddelete="Non potete cancellare le cartelle di sistema"
_text._badfile="Non posso aprire la configurazione"
_text._badmaildir="Selezionate una directory posta valida"
_text._badparm="Parametri sconosciuti a ConfigYam:"
_text._badrename="Rinomina fallito..Codice="
_text._badsavefile="Non posso aprire il file in uscita"
_text._newexists="Il Nuovo nome del file già esiste"
_text._protected ="Non posso modificare questa linea"
_text._secondrun="Avete già un ConfigYam avviato" /* second run */
/**************************************************************************/
/* Help Messages to display with MUI bubble facility. */
/* */
/* Format is simple: help.ID where ID is the id specified on the MUI */
/* object statement. */
/* Similar approach for accessing the .guide information using the NODE */
/* option on the object statement. */
/* */
/**************************************************************************/
help.SQUIT=""""""
help.STEXT=""""""
help.CYCFG="""Selezionate la configurazione di Yam"""
help.CYMDR="""Selezionate la directory posta"""
help.CYALL="""Bi-cliccate per modificare una voce.\nSapete quello che fate?"""
help.CYFLD="""Drag-n-drop per riordinare, bi-cliccate\nper modificare la voce ma lasciate\ncosì come sono i primi 4"""
help.CYMCS="""Modificate la voce della configurazione principale.\nPremete Return per aggiornare la voce evidenziata."""
help.CYFL1="""Ordina per\n0=Prima i nuovi\n1=Prima i vecchi\n2=Mittente\n3=Oggetto"""
help.CYFL2="""Nome attuale del file della cartella.\nQuelli senza percorso si assumono\nessere nella directory posta\nselezionata"""
help.CYFL3="""Nome cartella"""
help.CYPR3="""Mostra entrambe le liste"""
help.CYFLI="""Inserisce una nuova cartella"""
help.CYFLX="""Nasconde la lista cartelle\nMostra la config principale"""
help.CYFLZ="""Cancella la cartella dalla\nconfigurazione di Yam"""
help.CYMCI="""Inserisce una nuova linea nella\nconfigurazione di Yam"""
help.CYMCX="""Nasconde la config principale.\nMostra la lista cartelle"""
help.CYMCZ="""Cancella la linea dalla\nconfigurazione di Yam"""
help.CYPR0="""Carica la configurazione\nselezionata"""
help.CYPR1="""Salva la configurazione\nselezionata"""
help.CYPR2="""Salva la configurazione\nin un nuovo file"""
help.CYPRQ="""Esci"""
Return